import {getSessionStorage, removeSessionStorage, setSessionStorage} from "@/util/storage/storage";
const USER_INFO = 'userInfo'

const ACCESS_TOKEN = 'token'
const STORE_INFO = 'storeInfo'

export const setUserInfo = (val) => {
  setSessionStorage(USER_INFO, val)
}

export const getUserInfo = () => {
  return getSessionStorage(USER_INFO);
};

export const clearUserInfo = () => {
  return removeSessionStorage(USER_INFO);
};

export const setAccessToken = (val) => {
  setSessionStorage(ACCESS_TOKEN, val);
};

export const getAccessToken = () => {
  return getSessionStorage(ACCESS_TOKEN);
};

export const clearAccessToken = () => {
  return removeSessionStorage(ACCESS_TOKEN);
};

export const clearLoginInfo = () => {
  clearUserInfo();
  clearAccessToken();
};

export const getUserWorkNo = () => {
  const userInfo = getUserInfo() || {};
  return userInfo.workNo || '';
};
